Skip to content

deps: bump the analyzers group and remediate the new Sonar rules - #162

Merged
ivanball merged 2 commits into
mainfrom
deps/analyzers-group-and-remediation
Jul 28, 2026
Merged

deps: bump the analyzers group and remediate the new Sonar rules#162
ivanball merged 2 commits into
mainfrom
deps/analyzers-group-and-remediation

Conversation

@ivanball

Copy link
Copy Markdown
Owner

Completes the Dependabot sweep. Bumps Meziantou.Analyzer 3.0.124 → 3.0.133 and SonarAnalyzer.CSharp 10.29 → 10.30 (was #147), held out of #161 because 10.30 ships three new rules that fail this build under TreatWarningsAsErrors.

Each was triaged on its merits rather than bulk-suppressed or bulk-applied.

S8949 (3 sites) — a real defect, fixed properly

SoftDeletedUserMiddleware called the cache and the soft-delete validator without a CancellationToken, even though all three APIs accept one. A client disconnect never cancelled the lookups. They now pass context.RequestAborted.

This one earned its keep: the bump found a genuine bug.

S8969 (38 sites) — mostly right, 4 wrong

34 were genuine redundant null-forgiving operators and are removed.

Four were wrong. The analyzer claimed the compiler already knew the expression was non-null; removing the operator immediately failed with CS8602 / CS8629. Those four are restored, and the rule is downgraded to suggestion in .editorconfig.

Under TreatWarningsAsErrors a false positive is a broken build, not a nudge, so a rule at this accuracy cannot gate CI. As a suggestion, real redundancies still surface.

S8970 (3 sites) — wrong at every site

It claims nullable warnings are disabled and the operator is pointless. Every flagged site is the deliberate null! / default! initializer pattern in a .razor component, where removing it fails with CS8625 / CS8604.

Suppressed via NoWarn in Directory.Build.props rather than .editorconfig, because a dotnet_diagnostic severity does not reach Razor-generated code — worth knowing for the next Razor-affecting rule.

Why not just suppress all three, or apply all three

The measured false-positive rate was 7 of 41. Applying blindly breaks the build; suppressing blindly would have discarded 34 real cleanups and missed a genuine cancellation bug. Both suppressions carry that reasoning inline for whoever revisits them.

Verification

  • Full solution Release: 2483/2483 green, 0 warnings, 0 errors.
  • facts --check clean.
  • 25 lock files regenerated.

Stacked on #161 conceptually but branched off main, so it will need gh pr update-branch after that merges.

ivanball and others added 2 commits July 28, 2026 09:51
Completes the Dependabot sweep. Bumps Meziantou.Analyzer 3.0.124 -> 3.0.133 and
SonarAnalyzer.CSharp 10.29.0.143774 -> 10.30.0.144632 (was #147), which was held
out of the consolidated bump PR because 10.30 ships three new rules that fail
this build under TreatWarningsAsErrors.

S8949 (3 sites) is a REAL defect and is fixed properly. SoftDeletedUserMiddleware
was calling the cache and the soft-delete validator without a CancellationToken,
even though all three APIs accept one, so a client disconnect never cancelled the
lookups. They now pass context.RequestAborted.

S8969 (38 sites) is mostly right: 34 were genuine redundant null-forgiving
operators and are removed. FOUR were wrong. At those the analyzer claimed the
compiler already knew the expression was non-null, and removing the operator
immediately failed with CS8602/CS8629. Those four are restored, and the rule is
downgraded to a suggestion in .editorconfig: under TreatWarningsAsErrors a false
positive is a broken build, not a nudge, so it cannot gate CI at that accuracy.

S8970 (3 sites) is wrong at every site it flags here. It claims nullable warnings
are disabled and the operator is pointless, but each site is the deliberate
`null!` / `default!` initializer pattern in a .razor component, where removing it
fails with CS8625/CS8604. Suppressed via NoWarn in Directory.Build.props rather
than .editorconfig, because a dotnet_diagnostic severity does not reach
Razor-generated code.

The measured false-positive rate (7 of 41) is why neither nullability rule is
left at error severity. The compiler is the authority on nullability, not the
analyzer; both suppressions carry that reasoning inline for whoever revisits them.

Full solution 2483/2483 green in Release, 0 warnings; facts --check clean;
25 lock files regenerated.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RpWirEitGZ2AMEQhd7NCD9
@ivanball
ivanball merged commit c11056c into main Jul 28, 2026
14 checks passed
@ivanball
ivanball deleted the deps/analyzers-group-and-remediation branch July 28, 2026 14:49
ivanball added a commit that referenced this pull request Jul 29, 2026
The solution-wide restore only reaches projects listed in MMCA.Common.slnx, so
the four that deliberately sit outside it kept stale "requested" versions after
the analyzer bumps in #162 and earlier:

- Source/Presentation/MMCA.Common.UI.Maui (ADR-042, its own windows job)
- Tests/Presentation/MMCA.Common.UI.E2E.Tests
- Tests/Presentation/MMCA.Common.UI.Gallery
- Tests/Core/MMCA.Common.Infrastructure.Redis.Tests

Meziantou.Analyzer 3.0.123/3.0.124 to 3.0.133, SonarAnalyzer.CSharp
10.29.0.143774 to 10.30.0.144632, and the Microsoft.IdentityModel transitives
8.19.2 to 8.21.0, all now matching Directory.Packages.props.

No behavior change. CI restores without --locked-mode (ci.yml:85), so these
projects were already compiling against the current analyzers; this only
realigns the recorded lock state. The three non-MAUI projects build clean in
Release locally, and MAUI is covered by its dedicated windows job.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ivanball ivanball mentioned this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant